{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Run Flask\n",
    "Run your flask app (`wsgi.py`) from here and test it from a separate notebook."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: Flask in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (2.0.3)\n",
      "Requirement already satisfied: gunicorn in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (20.1.0)\n",
      "Requirement already satisfied: jupyter in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (1.0.0)\n",
      "Requirement already satisfied: numpy in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (1.19.2)\n",
      "Requirement already satisfied: pandas in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (1.2.4)\n",
      "Requirement already satisfied: matplotlib in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 6)) (3.4.1)\n",
      "Requirement already satisfied: seaborn in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 7)) (0.11.2)\n",
      "Requirement already satisfied: scikit-learn in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 8)) (0.24.1)\n",
      "Requirement already satisfied: xgboost in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 9)) (1.5.2)\n",
      "Requirement already satisfied: kaggle in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 10)) (1.5.12)\n",
      "Requirement already satisfied: opendatasets in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 11)) (0.1.20)\n",
      "Requirement already satisfied: requests in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 12)) (2.27.1)\n",
      "Requirement already satisfied: ipyplot in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 13)) (1.1.1)\n",
      "Requirement already satisfied: scikit-image in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 14)) (0.19.1)\n",
      "Requirement already satisfied: nbformat in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 15)) (5.1.3)\n",
      "Requirement already satisfied: nbconvert==6.4.4 in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 16)) (6.4.4)\n",
      "Requirement already satisfied: inquirer in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 17)) (2.9.2)\n",
      "Requirement already satisfied: pygments>=2.4.1 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (2.11.2)\n",
      "Requirement already satisfied: mistune<2,>=0.8.1 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (0.8.4)\n",
      "Requirement already satisfied: jupyter-core in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (4.9.1)\n",
      "Requirement already satisfied: entrypoints>=0.2.2 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (0.3)\n",
      "Requirement already satisfied: testpath in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (0.5.0)\n",
      "Requirement already satisfied: pandocfilters>=1.4.1 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (1.5.0)\n",
      "Requirement already satisfied: beautifulsoup4 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (4.8.2)\n",
      "Requirement already satisfied: defusedxml in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (0.7.1)\n",
      "Requirement already satisfied: jupyterlab-pygments in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (0.1.2)\n",
      "Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (0.5.9)\n",
      "Requirement already satisfied: bleach in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (4.1.0)\n",
      "Requirement already satisfied: jinja2>=2.4 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (3.1.1)\n",
      "Requirement already satisfied: traitlets>=5.0 in /opt/app-root/lib/python3.8/site-packages (from nbconvert==6.4.4->-r requirements.txt (line 16)) (5.1.1)\n",
      "Requirement already satisfied: Werkzeug>=2.0 in /opt/app-root/lib/python3.8/site-packages (from Flask->-r requirements.txt (line 1)) (2.0.2)\n",
      "Requirement already satisfied: itsdangerous>=2.0 in /opt/app-root/lib/python3.8/site-packages (from Flask->-r requirements.txt (line 1)) (2.1.2)\n",
      "Requirement already satisfied: click>=7.1.2 in /opt/app-root/lib/python3.8/site-packages (from Flask->-r requirements.txt (line 1)) (8.0.3)\n",
      "Requirement already satisfied: setuptools>=3.0 in /opt/app-root/lib/python3.8/site-packages (from gunicorn->-r requirements.txt (line 2)) (60.9.3)\n",
      "Requirement already satisfied: jupyter-console in /opt/app-root/lib/python3.8/site-packages (from jupyter->-r requirements.txt (line 3)) (6.4.3)\n",
      "Requirement already satisfied: qtconsole in /opt/app-root/lib/python3.8/site-packages (from jupyter->-r requirements.txt (line 3)) (5.2.2)\n",
      "Requirement already satisfied: ipykernel in /opt/app-root/lib/python3.8/site-packages (from jupyter->-r requirements.txt (line 3)) (6.6.1)\n",
      "Requirement already satisfied: notebook in /opt/app-root/lib/python3.8/site-packages (from jupyter->-r requirements.txt (line 3)) (6.4.6)\n",
      "Requirement already satisfied: ipywidgets in /opt/app-root/lib/python3.8/site-packages (from jupyter->-r requirements.txt (line 3)) (7.7.0)\n",
      "Requirement already satisfied: python-dateutil>=2.7.3 in /opt/app-root/lib/python3.8/site-packages (from pandas->-r requirements.txt (line 5)) (2.8.2)\n",
      "Requirement already satisfied: pytz>=2017.3 in /opt/app-root/lib/python3.8/site-packages (from pandas->-r requirements.txt (line 5)) (2021.3)\n",
      "Requirement already satisfied: pillow>=6.2.0 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (9.0.0)\n",
      "Requirement already satisfied: cycler>=0.10 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (0.11.0)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (1.3.2)\n",
      "Requirement already satisfied: pyparsing>=2.2.1 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (3.0.6)\n",
      "Requirement already satisfied: scipy>=1.0 in /opt/app-root/lib/python3.8/site-packages (from seaborn->-r requirements.txt (line 7)) (1.6.2)\n",
      "Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/app-root/lib/python3.8/site-packages (from scikit-learn->-r requirements.txt (line 8)) (3.0.0)\n",
      "Requirement already satisfied: joblib>=0.11 in /opt/app-root/lib/python3.8/site-packages (from scikit-learn->-r requirements.txt (line 8)) (1.1.0)\n",
      "Requirement already satisfied: certifi in /opt/app-root/lib/python3.8/site-packages (from kaggle->-r requirements.txt (line 10)) (2021.10.8)\n",
      "Requirement already satisfied: urllib3 in /opt/app-root/lib/python3.8/site-packages (from kaggle->-r requirements.txt (line 10)) (1.26.8)\n",
      "Requirement already satisfied: tqdm in /opt/app-root/lib/python3.8/site-packages (from kaggle->-r requirements.txt (line 10)) (4.62.3)\n",
      "Requirement already satisfied: six>=1.10 in /opt/app-root/lib/python3.8/site-packages (from kaggle->-r requirements.txt (line 10)) (1.16.0)\n",
      "Requirement already satisfied: python-slugify in /opt/app-root/lib/python3.8/site-packages (from kaggle->-r requirements.txt (line 10)) (6.1.1)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /opt/app-root/lib/python3.8/site-packages (from requests->-r requirements.txt (line 12)) (3.3)\n",
      "Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/app-root/lib/python3.8/site-packages (from requests->-r requirements.txt (line 12)) (2.0.10)\n",
      "Requirement already satisfied: IPython in /opt/app-root/lib/python3.8/site-packages (from ipyplot->-r requirements.txt (line 13)) (8.0.0rc1)\n",
      "Requirement already satisfied: shortuuid in /opt/app-root/lib/python3.8/site-packages (from ipyplot->-r requirements.txt (line 13)) (1.0.8)\n",
      "Requirement already satisfied: tifffile>=2019.7.26 in /opt/app-root/lib/python3.8/site-packages (from scikit-image->-r requirements.txt (line 14)) (2021.11.2)\n",
      "Requirement already satisfied: PyWavelets>=1.1.1 in /opt/app-root/lib/python3.8/site-packages (from scikit-image->-r requirements.txt (line 14)) (1.2.0)\n",
      "Requirement already satisfied: packaging>=20.0 in /opt/app-root/lib/python3.8/site-packages (from scikit-image->-r requirements.txt (line 14)) (21.3)\n",
      "Requirement already satisfied: networkx>=2.2 in /opt/app-root/lib/python3.8/site-packages (from scikit-image->-r requirements.txt (line 14)) (2.6.3)\n",
      "Requirement already satisfied: imageio>=2.4.1 in /opt/app-root/lib/python3.8/site-packages (from scikit-image->-r requirements.txt (line 14)) (2.13.5)\n",
      "Requirement already satisfied: ipython-genutils in /opt/app-root/lib/python3.8/site-packages (from nbformat->-r requirements.txt (line 15)) (0.2.0)\n",
      "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /opt/app-root/lib/python3.8/site-packages (from nbformat->-r requirements.txt (line 15)) (4.3.3)\n",
      "Requirement already satisfied: readchar>=2.0.1 in /opt/app-root/lib/python3.8/site-packages (from inquirer->-r requirements.txt (line 17)) (3.0.5)\n",
      "Requirement already satisfied: blessed>=1.19.0 in /opt/app-root/lib/python3.8/site-packages (from inquirer->-r requirements.txt (line 17)) (1.19.1)\n",
      "Requirement already satisfied: python-editor>=1.0.4 in /opt/app-root/lib/python3.8/site-packages (from inquirer->-r requirements.txt (line 17)) (1.0.4)\n",
      "Requirement already satisfied: wcwidth>=0.1.4 in /opt/app-root/lib/python3.8/site-packages (from blessed>=1.19.0->inquirer->-r requirements.txt (line 17)) (0.2.5)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in /opt/app-root/lib/python3.8/site-packages (from jinja2>=2.4->nbconvert==6.4.4->-r requirements.txt (line 16)) (2.0.1)\n",
      "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /opt/app-root/lib/python3.8/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->-r requirements.txt (line 15)) (0.18.0)\n",
      "Requirement already satisfied: importlib-resources>=1.4.0 in /opt/app-root/lib/python3.8/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->-r requirements.txt (line 15)) (5.4.0)\n",
      "Requirement already satisfied: attrs>=17.4.0 in /opt/app-root/lib/python3.8/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->-r requirements.txt (line 15)) (21.4.0)\n",
      "Requirement already satisfied: jupyter-client>=6.1.5 in /opt/app-root/lib/python3.8/site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert==6.4.4->-r requirements.txt (line 16)) (7.1.0)\n",
      "Requirement already satisfied: nest-asyncio in /opt/app-root/lib/python3.8/site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert==6.4.4->-r requirements.txt (line 16)) (1.5.4)\n",
      "Requirement already satisfied: soupsieve>=1.2 in /opt/app-root/lib/python3.8/site-packages (from beautifulsoup4->nbconvert==6.4.4->-r requirements.txt (line 16)) (2.3.1)\n",
      "Requirement already satisfied: webencodings in /opt/app-root/lib/python3.8/site-packages (from bleach->nbconvert==6.4.4->-r requirements.txt (line 16)) (0.5.1)\n",
      "Requirement already satisfied: tornado<7.0,>=4.2 in /opt/app-root/lib/python3.8/site-packages (from ipykernel->jupyter->-r requirements.txt (line 3)) (6.1)\n",
      "Requirement already satisfied: debugpy<2.0,>=1.0.0 in /opt/app-root/lib/python3.8/site-packages (from ipykernel->jupyter->-r requirements.txt (line 3)) (1.5.1)\n",
      "Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in /opt/app-root/lib/python3.8/site-packages (from ipykernel->jupyter->-r requirements.txt (line 3)) (0.1.3)\n",
      "Requirement already satisfied: jedi>=0.16 in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (0.17.2)\n",
      "Requirement already satisfied: pexpect>4.3 in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (4.8.0)\n",
      "Requirement already satisfied: pickleshare in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (0.7.5)\n",
      "Requirement already satisfied: backcall in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (0.2.0)\n",
      "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (3.0.24)\n",
      "Requirement already satisfied: stack-data in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (0.1.3)\n",
      "Requirement already satisfied: decorator in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (5.1.1)\n",
      "Requirement already satisfied: black in /opt/app-root/lib/python3.8/site-packages (from IPython->ipyplot->-r requirements.txt (line 13)) (21.6b0)\n",
      "Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /opt/app-root/lib/python3.8/site-packages (from ipywidgets->jupyter->-r requirements.txt (line 3)) (2.0.0b1)\n",
      "Requirement already satisfied: widgetsnbextension~=3.6.0 in /opt/app-root/lib/python3.8/site-packages (from ipywidgets->jupyter->-r requirements.txt (line 3)) (3.6.0)\n",
      "Requirement already satisfied: pyzmq>=17 in /opt/app-root/lib/python3.8/site-packages (from notebook->jupyter->-r requirements.txt (line 3)) (22.3.0)\n",
      "Requirement already satisfied: Send2Trash>=1.8.0 in /opt/app-root/lib/python3.8/site-packages (from notebook->jupyter->-r requirements.txt (line 3)) (1.8.1b0)\n",
      "Requirement already satisfied: terminado>=0.8.3 in /opt/app-root/lib/python3.8/site-packages (from notebook->jupyter->-r requirements.txt (line 3)) (0.12.1)\n",
      "Requirement already satisfied: prometheus-client in /opt/app-root/lib/python3.8/site-packages (from notebook->jupyter->-r requirements.txt (line 3)) (0.12.0)\n",
      "Requirement already satisfied: argon2-cffi in /opt/app-root/lib/python3.8/site-packages (from notebook->jupyter->-r requirements.txt (line 3)) (21.3.0)\n",
      "Requirement already satisfied: text-unidecode>=1.3 in /opt/app-root/lib/python3.8/site-packages (from python-slugify->kaggle->-r requirements.txt (line 10)) (1.3)\n",
      "Requirement already satisfied: qtpy in /opt/app-root/lib/python3.8/site-packages (from qtconsole->jupyter->-r requirements.txt (line 3)) (2.0.1)\n",
      "Requirement already satisfied: zipp>=3.1.0 in /opt/app-root/lib/python3.8/site-packages (from importlib-resources>=1.4.0->jsonschema!=2.5.0,>=2.4->nbformat->-r requirements.txt (line 15)) (3.7.0)\n",
      "Requirement already satisfied: parso<0.8.0,>=0.7.0 in /opt/app-root/lib/python3.8/site-packages (from jedi>=0.16->IPython->ipyplot->-r requirements.txt (line 13)) (0.7.1)\n",
      "Requirement already satisfied: ptyprocess>=0.5 in /opt/app-root/lib/python3.8/site-packages (from pexpect>4.3->IPython->ipyplot->-r requirements.txt (line 13)) (0.7.0)\n",
      "Requirement already satisfied: argon2-cffi-bindings in /opt/app-root/lib/python3.8/site-packages (from argon2-cffi->notebook->jupyter->-r requirements.txt (line 3)) (21.2.0)\n",
      "Requirement already satisfied: regex>=2020.1.8 in /opt/app-root/lib/python3.8/site-packages (from black->IPython->ipyplot->-r requirements.txt (line 13)) (2021.11.10)\n",
      "Requirement already satisfied: mypy-extensions>=0.4.3 in /opt/app-root/lib/python3.8/site-packages (from black->IPython->ipyplot->-r requirements.txt (line 13)) (0.4.3)\n",
      "Requirement already satisfied: appdirs in /opt/app-root/lib/python3.8/site-packages (from black->IPython->ipyplot->-r requirements.txt (line 13)) (1.4.4)\n",
      "Requirement already satisfied: toml>=0.10.1 in /opt/app-root/lib/python3.8/site-packages (from black->IPython->ipyplot->-r requirements.txt (line 13)) (0.10.2)\n",
      "Requirement already satisfied: pathspec<1,>=0.8.1 in /opt/app-root/lib/python3.8/site-packages (from black->IPython->ipyplot->-r requirements.txt (line 13)) (0.9.0)\n",
      "Requirement already satisfied: executing in /opt/app-root/lib/python3.8/site-packages (from stack-data->IPython->ipyplot->-r requirements.txt (line 13)) (0.8.2)\n",
      "Requirement already satisfied: asttokens in /opt/app-root/lib/python3.8/site-packages (from stack-data->IPython->ipyplot->-r requirements.txt (line 13)) (2.0.5)\n",
      "Requirement already satisfied: pure-eval in /opt/app-root/lib/python3.8/site-packages (from stack-data->IPython->ipyplot->-r requirements.txt (line 13)) (0.2.1)\n",
      "Requirement already satisfied: cffi>=1.0.1 in /opt/app-root/lib/python3.8/site-packages (from argon2-cffi-bindings->argon2-cffi->notebook->jupyter->-r requirements.txt (line 3)) (1.15.0)\n",
      "Requirement already satisfied: pycparser in /opt/app-root/lib/python3.8/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->notebook->jupyter->-r requirements.txt (line 3)) (2.21)\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "!{sys.executable} -m pip install -r requirements.txt\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " * Serving Flask app 'wsgi.py' (lazy loading)\n",
      " * Environment: development\n",
      " * Debug mode: on\n",
      "config\n",
      "['Path', 'Data', 'Model', 'Run']\n",
      " * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n",
      " * Restarting with watchdog (inotify)\n",
      " * Debugger is active!\n",
      " * Debugger PIN: 102-304-955\n",
      "config\n",
      "['Path', 'Data', 'Model', 'Run']\n",
      "127.0.0.1 - - [28/Mar/2022 19:40:36] \"GET /status HTTP/1.1\" 200 -\n",
      "127.0.0.1 - - [28/Mar/2022 19:40:37] \"POST /predictions HTTP/1.1\" 200 -\n",
      "127.0.0.1 - - [28/Mar/2022 19:40:38] \"POST /predictions HTTP/1.1\" 200 -\n"
     ]
    }
   ],
   "source": [
    "!FLASK_ENV=development FLASK_APP=wsgi.py flask run"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
